import React, { Component } from "react";

export default class App extends Component {
    a = 1
    // state = {
    //     // mytext:"收藏"
    //     myShow: true
    // }

    constructor(){
        super()
        this.state = {
            myShow: true,
            myNameShow: true
        }
    }
    render() {
        // var text = "喜欢"
        return (
            <div>
                <h1>Welcome to Zane's React dev-{this.state.myNameShow?'Zaneact':'Dongdongact'}</h1>
                
                <button onClick={() => {
                    // text = "取消喜欢"
                    // this.state.text = "取消喜欢"
                    this.setState({
                        // mytext:"取消收藏"
                        myShow: !this.state.myShow,
                        myNameShow: !this.state.myNameShow
                    } )// 间接修改状态

                    if(this.state.myShow){
                        console.log("收藏逻辑")
                    }else{
                        console.log("取消收藏逻辑")
                    }
                }}>{this.state.myShow?'收藏':'取消收藏'}</button>
            </div>
        )
    }
}